#ifndef __PTHREAD_H
#define __PTHREAD_H

#include "Wed_errno.h"

typedef void * pthread_t;
typedef struct pthread_attr {
    unsigned char data[32];
} pthread_attr_t;

typedef void * pthread_mutex_t;
typedef struct pthread_mutex {
    unsigned char data[32];
} pthread_mutexattr_t;

/* Mutex types.  */
enum{
        PTHREAD_MUTEX_TIMED_NP,
        PTHREAD_MUTEX_RECURSIVE_NP,
        PTHREAD_MUTEX_ERRORCHECK_NP,
        PTHREAD_MUTEX_ADAPTIVE_NP,
        PTHREAD_MUTEX_NORMAL = PTHREAD_MUTEX_TIMED_NP,
        PTHREAD_MUTEX_ERRORCHECK = PTHREAD_MUTEX_ERRORCHECK_NP,
        PTHREAD_MUTEX_RECURSIVE = PTHREAD_MUTEX_RECURSIVE_NP,
        PTHREAD_MUTEX_DEFAULT = PTHREAD_MUTEX_NORMAL,

    };

#ifdef __cplusplus
extern "C" {
#endif

    /* Thread attribute handling.  */

    /**
     * \brief  Initialize thread attribute *ATTR with default attributes
     *
     * Initialize thread attribute *ATTR with default attributes
     * (detachstate is PTHREAD_JOINABLE, scheduling policy is SCHED_OTHER,
     * no user-provided stack).
     */
    extern int pthread_attr_init (pthread_attr_t *p_attr);

    /* Functions for handling mutex attributes.  */

    /* Initialize mutex attribute object ATTR with default attributes
       (kind is PTHREAD_MUTEX_TIMED_NP).  */
    extern int pthread_mutexattr_init (pthread_mutexattr_t *p_attr);

    /* Destroy mutex attribute object ATTR.  */
    extern int pthread_mutexattr_destroy (pthread_mutexattr_t *p_attr);

    /* Set the mutex kind attribute in *ATTR to KIND (either PTHREAD_MUTEX_NORMAL,
       PTHREAD_MUTEX_RECURSIVE, PTHREAD_MUTEX_ERRORCHECK, or
       PTHREAD_MUTEX_DEFAULT).  */
    extern int pthread_mutexattr_settype (
            pthread_mutexattr_t *p_attr,
            int type);

    /* Mutex handling.  */

    /* Initialize a mutex.  */
    extern int pthread_mutex_init (
        pthread_mutex_t *p_mutex,
        const pthread_mutexattr_t *p_mutexattr);

    /* Destroy a mutex.  */
    extern int pthread_mutex_destroy (pthread_mutex_t *p_mutex);

    /* Lock a mutex.  */
    extern int pthread_mutex_lock (pthread_mutex_t *p_mutex);

    /* Unlock a mutex.  */
    extern int pthread_mutex_unlock (pthread_mutex_t *p_mutex);
#ifdef __cplusplus
}
#endif

#endif /* __PTHREAD_H */




